package com.shanjinjian.springblog.controller;

import com.shanjinjian.springblog.service.IPortalService;
import com.shanjinjian.springblog.util.CommonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@Controller
public class PortalController {

    @Autowired
    IPortalService portalService;

    @RequestMapping("index")
    public String index(HttpServletRequest request) {
        //返回到主页
        //访问主页时记录访问地址IP
        String clientIp = CommonUtil.getIp2(request);
        log.info(clientIp);

        //TODO 顶部标签页做成可配置的形式
        //TODO 主体部分的文章推荐
        //TODO 右侧最新文章
        //TODO 右侧热门文章


        portalService.insertClientAccess(clientIp);
        return "index";
    }
}
